package com.huifaapp.mall.bean;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;

/**
 * Created by Administrator on 2018/1/12.
 */

public class GoodsListBean {


    public static class Attr {
        public static final String GOODSIMG = "goodsImg";
        public static final String GOODSNAME="goodsName";
        public static final String PRICE="price";
        public static final String ORGINPRICE="orginPrice";
        public static final String ISSEVENBACK="isSevenBack";
        public static final String GOODSID="goodsId";
        public static final String STOREID="storeId";
        public static final String PARAM="param";
        public static final String COUNT="count";
        public static final String ISREVICE="isRevice";

    }
    public GoodsListBean() {
    }
    public GoodsListBean(String goodsImg,String goodsName,double price,double orginPrice,String isSevenBack,String goodsId,String storeId,
                         String param,int count,String isRevice) {
        super();
        this.goodsImg=goodsImg;
        this.goodsName=goodsName;
        this.price=price;
        this.orginPrice=orginPrice;
        this.isSevenBack=isSevenBack;
        this.goodsId=goodsId;
        this.storeId=storeId;
        this.param=param;
        this.count=count;
        this.isRevice=isRevice;
    }
    /**
     * goodsImg : http://file.jhjvip.cn/images/default.jpg
     * goodsName : 山婆婆 黄桃水罐头
     * price : 25.0
     * orginPrice : 18.8
     * isSevenBack :
     * goodsId : 10001
     * storeId : 1007
     * param : {"color":"white","brand":"泡泡堂"}
     * count : 5
     */

    private String goodsImg;
    private String goodsName;
    private double price;
    private double orginPrice;
    private String isSevenBack;
    private String goodsId;
    private String storeId;
    private String param;
    private int count;
    private String isRevice;


    public static ArrayList<GoodsListBean> newInstanceList(String jsonDatas) {
        ArrayList<GoodsListBean> AdvertDatas = new ArrayList<GoodsListBean>();

        try {
            JSONArray arr = new JSONArray(jsonDatas);
            int size = null == arr ? 0 : arr.length();
            for (int i = 0; i < size; i++) {
                JSONObject obj = arr.getJSONObject(i);
                String goodsImg = obj.optString(Attr.GOODSIMG);
                String goodsName=obj.optString(Attr.GOODSNAME);
                double price=obj.optDouble(Attr.PRICE);
                double orginPrice=obj.optDouble(Attr.ORGINPRICE);
                String isSevenBack=obj.optString(Attr.ISSEVENBACK);
                String goodsId=obj.optString(Attr.GOODSID);
                String storeId=obj.optString(Attr.STOREID);
                String param=obj.optString(Attr.PARAM);
                Integer count=obj.optInt(Attr.COUNT);
                String isRevice=obj.optString(Attr.ISREVICE);
                AdvertDatas.add(new GoodsListBean(goodsImg,goodsName,price,orginPrice,isSevenBack,goodsId,storeId,param,count,isRevice));
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return AdvertDatas;
    }

    public String getIsRevice() {
        return isRevice;
    }

    public void setIsRevice(String isRevice) {
        this.isRevice = isRevice;
    }

    public String getGoodsImg() {
        return goodsImg;
    }

    public void setGoodsImg(String goodsImg) {
        this.goodsImg = goodsImg;
    }

    public String getGoodsName() {
        return goodsName;
    }

    public void setGoodsName(String goodsName) {
        this.goodsName = goodsName;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public double getOrginPrice() {
        return orginPrice;
    }

    public void setOrginPrice(double orginPrice) {
        this.orginPrice = orginPrice;
    }

    public String getIsSevenBack() {
        return isSevenBack;
    }

    public void setIsSevenBack(String isSevenBack) {
        this.isSevenBack = isSevenBack;
    }

    public String getGoodsId() {
        return goodsId;
    }

    public void setGoodsId(String goodsId) {
        this.goodsId = goodsId;
    }

    public String getStoreId() {
        return storeId;
    }

    public void setStoreId(String storeId) {
        this.storeId = storeId;
    }

    public String getParam() {
        return param;
    }

    public void setParam(String param) {
        this.param = param;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }
}
